package com.bdsy.business.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bdsy.business.dao.ShopCarMapper;
import com.bdsy.business.model.ShopCar;
import com.bdsy.business.service.ShopCarService;
import com.bdsy.common.utils.DateUtil;

@Service("shopCarService")
public class ShopCarServiceImpl implements ShopCarService {

	@Autowired
	ShopCarMapper shopCarMapper;
	
	@Override
	public boolean insert(ShopCar shopCar) {
		shopCar.setId((int)((Math.random()*9+1)*10000000));
		shopCar.setAddTime(DateUtil.getCurrentDate());
		int result = shopCarMapper.insert(shopCar);
		return result>0?true:false;
	}

	@Override
	public int count(String userId) {
		int count = shopCarMapper.count(userId);
		return count;
	}

	@Override
	public boolean delete(int shopId) {
		int result = shopCarMapper.delete(shopId);
		return result>0?true:false;
	}

	@Override
	public List<Map> selectShopCarById(String userId) {
		List<Map> shopCarList = shopCarMapper.selectShopCarById(userId);
		return shopCarList;
	}

	@Override
	public List<ShopCar> selectShopCarbyParam(String userId, int shopId) {
		List<ShopCar> shopCar = shopCarMapper.selectShopCarbyParam(userId, shopId);
		return shopCar;
	}

	@Override
	public boolean deleteShopCar(List<String> ids) {
		int result = shopCarMapper.deleteShopCar(ids);
		return result>0?true:false;
	}

	@Override
	public List<Map> selectZlShopCarById(String userId) {
		List<Map> zlShopCarList = shopCarMapper.selectZlShopCarById(userId);
		return zlShopCarList;
	}

}
